<template>
  <section class="webview fixHeight">
    <el-scrollbar style="height:100%">
      <el-form ref="form" :model="detail" label-width="100px" class="form">
		  <el-form-item label="城市">
		    <el-select v-model="detail.regionId" placeholder="请选择">
		      <el-option
		        v-for="item in resourcesList"
		        :key="item.regionId"
		        :label="item.regionName"
		        :value="item.regionId"
		      />
		    </el-select>
		  </el-form-item>
        <el-form-item label="类型名称">
          <el-input v-model="detail.name" />
        </el-form-item> 
		 <el-form-item label="下限价格">
          <el-input v-model="detail.downPrice" />
        </el-form-item> 
		<el-form-item label="上限价格">
          <el-input v-model="detail.topPrice" />
        </el-form-item>
		
		
        
		
        <el-form-item>
          <el-button type="primary" @click="submit">提交</el-button>
          <el-button @click="cancel">返回</el-button>
        </el-form-item>
      </el-form>
    </el-scrollbar>
  </section>
</template>
<script>
import {openList, screenadd,screenupdate } from '@/api/api'
export default {
  data() {
    return {
		fileListIntroduce: [],
      resourcesList: [],
      developersIdOptions: [],
	   areaList: [],
      permit: {
        'boundBuilding': '',
        'issuingTime': '',
        'permitNum': ''
      },
      detail: {
          "downPrice": '',
          "name": "",
          "regionId": "",
          "topPrice": '',
          "type": 2
      }
    }
  },
  created() {
	  if (this.$route.query.item) {
	    this.detail = JSON.parse(this.$route.query.item)
	  }
      openList().then((data) => {
        this.resourcesList = data.data
      })
  },
  methods: {
	 
    // 添加/编辑
    submit() {
      // 验证不通过则不提交
      if (!this.vertify()) {
        return false
      }
	  var prad=this.detail;
      const param = JSON.parse(JSON.stringify(prad))
      if (this.$route.query.item) {
        // 编辑
        screenupdate(prad).then(data => {
          Is.tip('编辑成功', 2000, 'success')
          this.$router.back()
        })
      } else {
        // 新增
        screenadd(prad).then(data => {
          Is.tip('添加成功', 2000, 'success')
          this.$router.back()
        })
      }
    },
    // 返回
    cancel() {
      this.$router.back()
    },
    vertify() {
      // if (Is.empty(this.detail.title)) {
      //   Is.tip('请输入标题')
      //   return false
      // }
      return true
    }
  }}
</script>
